#include<bits/stdc++.h>
using namespace std;
long long pda,pdb;
long long t,n,m,l,mv,w[100005],ans=0,sum=0,p[1000005],f,cur;
struct node{
	long long d,v,a;
}car[100015];
struct node1{
	long long e,s,able=0;
}use[100015];
int check(){
	int x=0; 
	for(int i=1;i<=n;i++){
		 for(int j=1;j<=m;j++){
			 if(car[i].d<=w[j]&&2*car[i].a*(w[j]-car[i].d)+car[i].v*car[i].v>mv*mv){
				x++;
				break;
			 }
		 }
	}
	return x;
}
int del(){
	long long u=pow(2,m),x=0,cura=0;
	ans=1e9+7;
	for(int k=0;k<u;k++){
		x=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if((k>>(j-1)&1)&&car[i].d<=w[j]&&2*car[i].a*(w[j]-car[i].d)+car[i].v*car[i].v>mv*mv){
					x++;
					break;
				}
			}
		}
		//cout<<sum<<" "<<x<<" "<<k<<endl;
		if(x==sum){
			//cout<<"xxx"<<endl;
			cur=k,cura=0;
			while(cur>0){
				if(cur&1) cura++;
				cur>>=1;
			}
			ans=min(ans,cura);
		}
	}
	return ans;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		cin>>n>>m>>l>>mv;
		pda=1,pdb=1,ans=0,sum=0;
		memset(p,0,sizeof p);
		for(int i=1;i<=n;i++){
			cin>>car[i].d>>car[i].v>>car[i].a;
			if(car[i].a!=0) pda=0;
			if(car[i].a<0) pdb=0;
		}
		for(int i=1;i<=m;i++){
			cin>>w[i];
			p[w[i]]++;
		}
		for(int i=1;i<=l;i++){
			p[i]=p[i-1]+p[i];
		}
		if(pda==1){
			for(int i=1;i<=n;i++){
				if(car[i].d<=w[m]&&car[i].v>mv){
					sum++;
				}
			}
			if(sum!=0)cout<<sum<<" "<<m-1<<endl;
			else cout<<0<<" "<<m<<endl;
			continue;
		}
		else if(pdb==1){
			for(int i=1;i<=n;i++){
				if(car[i].v>mv&&car[i].d<=w[m]){
					sum++;
				}
				else if(car[i].d<=w[m]&&2*car[i].a*(w[m]-car[i].d)+car[i].v*car[i].v>mv*mv){
					sum++;
				}
			}
			if(sum!=0)cout<<sum<<" "<<m-1<<endl;
			else cout<<0<<" "<<m<<endl;
			continue;
		}
		else{
			sum=check();
			if(sum!=0)cout<<sum<<" "<<m-del()<<endl;
			else cout<<0<<" "<<m<<endl;
			continue;
		}
	}
	return 0;
}
